package alg20241118;

public class Text {
    public int jewelleryValue(int[][] frame) {
        int m = frame.length;
        int n = frame[0].length;
        //1 创建表
        int[][] dp = new int[m + 1][n + 1];
        //2 初始化
        //添加了虚拟结点   dp[0][1]  = 0
        //3  填表
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]) + frame[i-1][j-1];
            }
        }
        //4  返回值
        return dp[m][n];
    }
}
